package com.dc.refactoring._5_简化函数调用._9_IntroduceParameterObject.oldObject;

import java.util.Date;
import java.util.List;

/**
 * Description: 账户
 * @author: gdc
 * @date: 2020/12/10
 * @version 1.0
 */
public class Account {

    /**
     * 账项列表
     */
    private List<Entry> entries;

    /**
     * 获取给定日期范围内的账项
     * @param start         开始日期
     * @param end           结束日期
     * @return              金额
     */
    double getFlowBetween(Date start, Date end) {
        double result = 0;
        for (Entry entry : entries) {
            if (entry.getChargeDate().compareTo(start) >= 0 && entry.getChargeDate().compareTo(end) <= 0) {
                result += entry.getItem();
            }
        }
        return result;
    }

}
